import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import 'element-ui/lib/theme-chalk/display.css'
import '@/styles/index.scss' // 自定义样式

import dataV from '@jiaminghi/data-view'

import VCalendar from 'v-calendar'

import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control

// set ElementUI lang to EN
// Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
Vue.use(ElementUI)
Vue.use(dataV)
Vue.use(VCalendar, {
  componentPrefix: 'vc'
})
Vue.config.productionTip = false

// 封装自定义指令 用来控制操作权
Vue.directive('permission', {
  inserted(el, binding) {
    // el 指令作用的元素的dom对象
    // console.log(el)
    const points = store.state.user.userInfo?.permissions || []
    if (!points.includes(binding.value)) {
      el.classList.add('is-disabled')
      // el.remove() // 删除元素
      el.disabled = true
    }
  }
})

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
